

UPDATE FLW_PAL_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = to_timestamp('2021-04-13 18:47:19.538', 'YYYY-MM-DD HH24:MI:SS.FF') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_PAL_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;



UPDATE FLW_LIC_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = to_timestamp('2021-04-13 18:47:20.858', 'YYYY-MM-DD HH24:MI:SS.FF') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_LIC_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;



UPDATE ACT_DE_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = to_timestamp('2021-04-13 18:47:21.590', 'YYYY-MM-DD HH24:MI:SS.FF') WHERE ID = 1 AND LOCKED = 0;

CREATE TABLE ACT_DE_MODEL_TAG_RELATION (id VARCHAR2(255) NOT NULL, model_tag_id VARCHAR2(255) NOT NULL, model_id VARCHAR2(255) NOT NULL, CONSTRAINT PK_ACT_DE_MODEL_TAG_RELATION PRIMARY KEY (id));

ALTER TABLE ACT_DE_MODEL_TAG_RELATION ADD CONSTRAINT fk_tag_relation_tag FOREIGN KEY (model_tag_id) REFERENCES ACT_DE_MODEL_TAG (id);

ALTER TABLE ACT_DE_MODEL_TAG_RELATION ADD CONSTRAINT fk_tag_relation_model FOREIGN KEY (model_id) REFERENCES ACT_DE_MODEL (id);

INSERT INTO ACT_DE_MODEL_TAG
            (
                id,
                name,
                tenant_id
            )
            SELECT
                regexp_replace(lower(SYS_GUID()), '(.{8})(.{4})(.{4})(.{4})(.{12})', '\1-\2-\3-\4-\5') AS id,
                tagandtenantid.tag as name,
                tagandtenantid.tenant_id as tenant_id
            FROM
                (SELECT distinct tag, tenant_id from ACT_DE_MODEL where tag is not null and tag != '' and tag != '__flowableSystemModel') tagandtenantid
            WHERE
                NOT EXISTS(select 1 from ACT_DE_MODEL_TAG modeltag WHERE modeltag.name = tagandtenantid.tag and modeltag.tenant_id = tagandtenantid.tenant_id);

INSERT INTO ACT_DE_MODEL_TAG_RELATION
            (
            id,
            model_tag_id,
            model_id
            )
            SELECT
            regexp_replace(lower(SYS_GUID()), '(.{8})(.{4})(.{4})(.{4})(.{12})', '\1-\2-\3-\4-\5') AS id,
            model_tag.id as model_tag_id,
            model.id as model_id
            FROM
            ACT_DE_MODEL_TAG model_tag,
            ACT_DE_MODEL model
            WHERE
            model_tag.name = model.tag;

ALTER TABLE ACT_DE_MODEL DROP COLUMN tag;

ALTER TABLE ACT_DE_MODEL_HISTORY RENAME COLUMN tag TO tags_json;

INSERT INTO ACT_DE_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('14', 'flowable', 'META-INF/liquibase/flowable-modeler-app-db-changelog.xml', SYSTIMESTAMP, 13, '7:1d09369c89f0b08279576a91fb0b0abd', 'createTable tableName=ACT_DE_MODEL_TAG_RELATION; addForeignKeyConstraint baseTableName=ACT_DE_MODEL_TAG_RELATION, constraintName=fk_tag_relation_tag, referencedTableName=ACT_DE_MODEL_TAG; addForeignKeyConstraint baseTableName=ACT_DE_MODEL_TAG_RELA...', '', 'EXECUTED', NULL, NULL, '3.5.3', '8339641885');

UPDATE ACT_DE_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;

